package com.heima.common.exception;

import com.heima.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常拦截器
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理业务异常信息
     */
    @ExceptionHandler(LeadNewsException.class)
    public ResponseResult handleLeadNewsException(LeadNewsException e) {
        return ResponseResult.errorResult(e.getStatus(), e.getMessage());
    }


    /**
     * 处理系统异常
     */
    @ExceptionHandler(Exception.class)
    public ResponseResult handleException(Exception e){
        return ResponseResult.errorResult(500,"系统异常"+e.getMessage());
    }

}
